//This robot follws a white line on a black surface


#define LEFT 1
#define RIGHT 0
int main()
{
	/*motor(LEFT, 100);
	motor(RIGHT, -100);
	sleep (2.0);
	ao();
	*/
	printf("Starting!\n");
	while(1)
{
	int v1, v2, forward, line, fwd, back;
	float ttime, time;
	line=800;
	back=-100;
	forward=50;
	time=0.00;
	ttime=0.15;
	v1=analog10(7);   // Left sensor
	v2=analog10(6);  //Right sensor
	// add in motor start
	if((v1<line)&&(v2>line)) //turn one way
	{
		motor(LEFT, back);
		motor(RIGHT, forward);
		sleep(ttime);
		printf("going left \n");

	}
	if((v2<line)&&(v1>line)) //turn the other time
	{
		motor(LEFT, forward);
		motor(RIGHT, back);
		sleep(ttime);
		printf("going right \n");

	}
	if((v2<line)&&(v1<line)) //if both are white
	{
		printf("stopping \n");
		break;

	}
	else
	{
		motor(LEFT, forward);
		motor(RIGHT, forward);
		sleep(time);
		printf("straight \n");
	}


}
ao();
}
